package com.hh.bidding.service.impl;

import com.hh.bidding.domain.BidTenderRules;
import com.hh.bidding.mapper.BidTenderRulesMapper;
import com.hh.bidding.service.IBidTenderRulesService;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 招标项目竞标规则表;(bid_tender_rules)表服务实现类
 * @author : http://www.chiner.pro
 * @date : 2025-9-11
 */
@Service
public class BidTenderRulesServiceImpl implements IBidTenderRulesService {
    @Resource
    private BidTenderRulesMapper bidTenderRulesMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    public BidTenderRules queryById(Integer id){
        return bidTenderRulesMapper.queryById(id);
    }

    public BidTenderRules selectBidTenderRulesBySid(Integer sid){
        return bidTenderRulesMapper.selectBidTenderRulesBySid(sid);
    }

    public BidTenderRules queryBySid(Long sid){
        return bidTenderRulesMapper.queryBySid(sid);
    }

    public BidTenderRules selectBidTenderRulesByHidAndSid(Integer hid,Integer sid){
        return bidTenderRulesMapper.selectBidTenderRulesByHidAndSid(hid,sid);
    }

    /**
     * 分页查询
     *
     * @param bidTenderRules 筛选条件
     * @return 查询结果
     */
    public List<BidTenderRules> selectBidTenderRulesList(BidTenderRules bidTenderRules){
        long total = bidTenderRulesMapper.count(bidTenderRules);
        return bidTenderRulesMapper.queryAllByLimit(bidTenderRules);
    }

    /**
     * 新增数据
     *
     * @param bidTenderRules 实例对象
     * @return 实例对象
     */
    public int insert(BidTenderRules bidTenderRules){
        bidTenderRules.setCreateTime(DateUtils.getNowDate());
        bidTenderRules.setCurrentCount(0);
        return bidTenderRulesMapper.insert(bidTenderRules);
    }

    /**
     * 更新数据
     *
     * @param bidTenderRules 实例对象
     * @return 实例对象
     */
    public int update(BidTenderRules bidTenderRules){
        bidTenderRules.setUpdateTime(DateUtils.getNowDate());
        return bidTenderRulesMapper.update(bidTenderRules);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    public boolean deleteById(Integer id){
        int total = bidTenderRulesMapper.deleteById(id);
        return total > 0;
    }
}
